package com.dhnsoft.boot.core.service;

import com.dhnsoft.boot.core.entity.User;
import com.dhnsoft.boot.core.event.LoginSuccessEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

/**
 * @author dhn
 * @version 1.0
 * @date 2023-09-05 17:53
 * @Desc
 */
@Service
public class SysService {
    @EventListener
    public void onEvent(LoginSuccessEvent event){
        System.out.println("==== SysService ===感知到事件"+event);
        User source = (User) event.getSource();
        recordLog(source.getUsername());

    }

    public void recordLog(String username){
        System.out.println(username + "登录信息已被记录");
    }
}
